import librosa
import numpy as np
import os
import sys
import matplotlib.pyplot as plt
from python_ai.common.xcommon import *

BASE_DIR, FILE_NAME = os.path.split(__file__)
path = '../../../../large_data/audio/_many_files/direction_data/test/lefts/cxz_left_0 (1).wav'
audio_path = os.path.join(BASE_DIR, path)

y, sr = librosa.load(audio_path, sr=None, res_type='kaiser_fast')
print_numpy_ndarray_info(y, 'y')  # (31744, )
print('sr', sr)  # (16000, )
M = librosa.feature.mfcc(y, sr=sr, n_mfcc=100)  # ATTENTION: frame: 2048, shift: 512
# print(M)
print_numpy_ndarray_info(M, 'M')  # (100, 63)
print((31744 - 2048) / 512)  # 58

plt.plot(y)
plt.show()
plt.plot(M.mean(axis=0))
plt.show()
